using System.Linq;using System.Xml.Linq;using Medianamik.Core.Sugar;using Medianamik.Core;using Medianamik.Core.DAL;using System.Web;using Medianamik.Client.Data; /* Ajouter les Using nécessaires à la compilation */using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace Medianamik.DummyWebSite.Data{
    /// <summary>
    /// Strongly-typed collection for the MedianamikExternalRedirect class.
    /// </summary>
    [Serializable]
    public partial class MedianamikExternalRedirectCollection : ReadOnlyList<MedianamikExternalRedirect, MedianamikExternalRedirectCollection>, ICollectionWithChildren<MedianamikExternalRedirectCollection, MedianamikExternalRedirect>
    {   
        public new IEnumerator<MedianamikExternalRedirect> GetEnumerator()
         {
             return base.GetEnumerator();
         }
    
        #region Load with paging
        public MedianamikExternalRedirectCollection Load(int pPageSize, int pPageIndex)
        {
            if (orderByCollection.Count == 0)
            {
                AddDefaultOrderBy();
            }
            
            Query qry = new Query(new MedianamikExternalRedirect().GetSchema());
            CheckLogicalDelete(qry);
            foreach (Where where in wheres)
                qry.AddWhere(where);
            foreach (BetweenAnd between in betweens)
                qry.AddBetweenAnd(between);
            qry.OrderByCollection = orderByCollection;
            qry.PageSize = pPageSize;
            qry.PageIndex = pPageIndex;
            using (IDataReader rdr = qry.ExecuteReader())
            {
                LoadAndCloseReader(rdr);
                _totalCount = qry.GetRecordCount();
                return this;
            }
        }
        public MedianamikExternalRedirectCollection Load(int pMaxElements)
        {
            return Load(pMaxElements, 1);
        }
        
        public MedianamikExternalRedirectCollection Load(ContentState contentState)
        {
            wheres.RemoveAll(w => w.ColumnName.Equals("Generation"));
            Where("Generation", (int)contentState);
            return Load();
        }
        
        public MedianamikExternalRedirectCollection Load(string cultureName, ContentState contentState, ActiveStatus status)
        {
            wheres.RemoveAll(w => w.ColumnName.Equals("CultureName"));
            Where("CultureName", cultureName);
            wheres.RemoveAll(w => w.ColumnName.Equals("Generation"));
            Where("Generation", (int)contentState);
            wheres.RemoveAll(w => w.ColumnName.Equals("IsActive"));
            if(status != ActiveStatus.All)
            {
                Where("IsActive", status == ActiveStatus.Activated ? true : false);
            }
            
            return Load();
        }
        
        #endregion
        
        public IEnumerable<MedianamikExternalRedirect> LoadByIDs(string ids)
        {
            return LoadByIDs(DataUtil.GetSelectedGuids(ids));
        }
        public IEnumerable<MedianamikExternalRedirect> LoadByIDs(IList<Guid> ids)
        {
            if (ids.Count > 0)
            {
                if (ids.Count == 1)
                    Where("NodeId", ids.First());
                else
                    Where("NodeId", Comparison.In, ids.Select(g => g.ToString()));
                
                return Load().ReorderByIds(ids);
            }
            
            return Enumerable.Empty<MedianamikExternalRedirect>();
        }
        
        public IEnumerable<MedianamikExternalRedirect> LoadByIDs(string ids, string cultureName)
        {
            return LoadByIDs(DataUtil.GetSelectedGuids(ids), cultureName);
        }
        public IEnumerable<MedianamikExternalRedirect> LoadByIDs(IList<Guid> ids, string cultureName)
        {
            wheres.RemoveAll(w => w.ColumnName.Equals("CultureName"));
            Where("CultureName", cultureName);
            
            return LoadByIDs(ids);
        }
        
        public IEnumerable<MedianamikExternalRedirect> LoadByIDs(string ids, string cultureName, ContentState contentState, ActiveStatus status)
        {
            return LoadByIDs(DataUtil.GetSelectedGuids(ids), cultureName, contentState, status);
        }
        public IEnumerable<MedianamikExternalRedirect> LoadByIDs(IList<Guid> ids, string cultureName, ContentState contentState, ActiveStatus status)
        {
            if (ids.Count > 0)
            {
                if (ids.Count == 1)
                    Where("NodeId", ids.First());
                else
                    Where("NodeId", Comparison.In, ids.Select(g => g.ToString()));
                return Load(cultureName, contentState, status)
                    .ReorderByIds(ids);
            }
            return Enumerable.Empty<MedianamikExternalRedirect>();
        }
        
        public new MedianamikExternalRedirectCollection Load()
        {
            if (orderByCollection.Count == 0)
            {
                AddDefaultOrderBy();
            }
            return base.Load();
        }
        private void AddDefaultOrderBy()
        {
            OrderByAsc("Position");
            OrderByDesc("CreatedOn");
        }
        
        
         
         public MedianamikExternalRedirectCollection(ContentState state) : this(System.Globalization.CultureInfo.CurrentUICulture.Name, default(Guid?), (int)state, ActiveStatus.Activated)
         { 
         }
         
        public MedianamikExternalRedirectCollection() : this(System.Globalization.CultureInfo.CurrentUICulture.Name, default(Guid?), default(int?), ActiveStatus.Activated) 
        {
        }
        
     public MedianamikExternalRedirectCollection(Guid pTypeId):this(System.Globalization.CultureInfo.CurrentUICulture.Name, pTypeId, default(int?), ActiveStatus.Activated)
     {
     }
     
     
     public MedianamikExternalRedirectCollection(string pCultureName): this(pCultureName, default(Guid?), default(int?), ActiveStatus.Activated)
     {
     }
     
     public MedianamikExternalRedirectCollection(string pCultureName, Guid pTypeId):this(pCultureName, new Guid?(pTypeId), default(int?), ActiveStatus.Activated)
     {    
     }
     
     public MedianamikExternalRedirectCollection(string pCultureName, ContentState state):this(pCultureName, default(Guid?),(int)state, ActiveStatus.Activated)
     {    
     }
          
     public MedianamikExternalRedirectCollection(string pCultureName, Guid pTypeId, ContentState state):this(pCultureName, new Guid?(pTypeId), (int)state, ActiveStatus.Activated)
     {    
     }
     
     private MedianamikExternalRedirectCollection(string pCultureName, Guid? pTypeId, int? pContentState, ActiveStatus status)
     {  
        if(pContentState.HasValue)
            {
                CurrentGeneration = pContentState.Value;
            }
            else
            {
                CurrentGeneration = System.Web.HttpContext.Current == null
                    ? (int)ContentState.Published
                    : new Medianamik.Client.Utility().GetGeneration(System.Web.HttpContext.Current.Request);
            }
        
        if(status != ActiveStatus.All)
        {
            Where("IsActive", status == ActiveStatus.Activated ? true : false);
        }
            
       Where("Generation", CurrentGeneration);
       Where("CultureName", pCultureName);
       if(pTypeId.HasValue)
       {
         Where("TypeId", pTypeId.Value);
       }
     } 
          
    public MedianamikExternalRedirectCollection LoadParentNodes(Guid pNodeId) 
    {
        return LoadParentNodes(pNodeId, false, 0, (ContentState)CurrentGeneration, ActiveStatus.Activated);
    }
    
    public MedianamikExternalRedirectCollection LoadParentNodes(Guid pNodeId, bool pInclusive) 
    {
        return LoadParentNodes(pNodeId, pInclusive, 0, (ContentState)CurrentGeneration, ActiveStatus.Activated);
    }
    
    public MedianamikExternalRedirectCollection LoadParentNodes(Guid pNodeId, bool pInclusive, int pMaxDepth) 
    {
        return LoadParentNodes(pNodeId, pInclusive, pMaxDepth, (ContentState)CurrentGeneration, ActiveStatus.Activated);
    }
    public MedianamikExternalRedirectCollection LoadParentNodes(Guid pNodeId, bool pInclusive, int pMaxDepth, ContentState contentState) 
    {
        return LoadParentNodes(pNodeId, pInclusive, pMaxDepth, contentState, ActiveStatus.Activated);
    }
    public MedianamikExternalRedirectCollection LoadParentNodes(Guid pNodeId, bool pInclusive, int pMaxDepth, ContentState contentState, ActiveStatus status) 
    {
     return LoadParentNodes(pNodeId, wheres.First(w => w.ColumnName.Equals("CultureName")).ParameterValue.ToString(),
        pInclusive, pMaxDepth, contentState, status);
    }
    
    public MedianamikExternalRedirectCollection LoadParentNodes(Guid pNodeId, string cultureName, bool pInclusive, int pMaxDepth, 
            ContentState contentState, ActiveStatus status)
    {
        int isActiveValue = -1;
        switch (status)
        {
            case ActiveStatus.Activated:
                isActiveValue = 1;
                break;
            case ActiveStatus.Deactivated:
                isActiveValue = 0;
                break;
        }
        StoredProcedure sp = new StoredProcedure("medianamik_LoadParentNodes");
        sp.Command.AddParameter("@TableName", "vw_gen_MedianamikExternalRedirect", DbType.String);
        sp.Command.AddParameter("@NodeId", pNodeId, DbType.Guid);
        sp.Command.AddParameter("@CultureName", cultureName, DbType.String);
        sp.Command.AddParameter("@Generation", (int)contentState, DbType.Int32);
        sp.Command.AddParameter("@MaxDepth", pMaxDepth, DbType.Int32);
        sp.Command.AddParameter("@IsActive", isActiveValue, DbType.Int32);
        sp.Command.AddParameter("@InclusiveChar", DataUtil.GetSQLInclusivityOperator(pInclusive), DbType.String);
        IDataReader rdr = sp.GetReader();
        this.Load(rdr);
        rdr.Close();
        return this;
    }
    
    public MedianamikExternalRedirectCollection LoadChildNodes(Guid pNodeId) 
    {
        return LoadChildNodes(pNodeId, false, 0, (ContentState)CurrentGeneration, ActiveStatus.Activated);
    }
    
    public MedianamikExternalRedirectCollection LoadChildNodes(Guid pNodeId, bool pInclusive) 
    {
        return LoadChildNodes(pNodeId, pInclusive, 0, (ContentState)CurrentGeneration, ActiveStatus.Activated);
    }
    
    public MedianamikExternalRedirectCollection LoadChildNodes(Guid pNodeId, bool pInclusive, int pMaxDepth)
    {
        return LoadChildNodes(pNodeId, pInclusive, pMaxDepth, (ContentState)CurrentGeneration, ActiveStatus.Activated);
    }
    
    public MedianamikExternalRedirectCollection LoadChildNodes(Guid pNodeId, bool pInclusive, int pMaxDepth, ContentState contentState) 
    {
        return LoadChildNodes(pNodeId, pInclusive, pMaxDepth, contentState, ActiveStatus.Activated);
    }
    
    public MedianamikExternalRedirectCollection LoadChildNodes(Guid pNodeId, bool pInclusive, int pMaxDepth, ContentState contentState, ActiveStatus status) 
    {
    return LoadChildNodes(pNodeId, wheres.First(w => w.ColumnName.Equals("CultureName")).ParameterValue.ToString(), pInclusive, pMaxDepth, contentState, status);
    }
    public MedianamikExternalRedirectCollection LoadChildNodes(Guid pNodeId, string cultureName, bool pInclusive, int pMaxDepth, 
            ContentState contentState, ActiveStatus status)
    {
        int isActiveValue = -1;
        switch (status)
        {
            case ActiveStatus.Activated:
                isActiveValue = 1;
                break;
            case ActiveStatus.Deactivated:
                isActiveValue = 0;
                break;
        }
        StoredProcedure sp = new StoredProcedure("medianamik_LoadChildNodes");
        sp.Command.AddParameter("@TableName", "vw_gen_MedianamikExternalRedirect", DbType.String);
        sp.Command.AddParameter("@NodeId", pNodeId, DbType.Guid);
        sp.Command.AddParameter("@CultureName", cultureName, DbType.String);
        sp.Command.AddParameter("@Generation", contentState, DbType.Int32);
        sp.Command.AddParameter("@MaxDepth", pMaxDepth, DbType.Int32);
        sp.Command.AddParameter("@IsActive", isActiveValue, DbType.Int32);
        sp.Command.AddParameter("@InclusiveChar", DataUtil.GetSQLInclusivityOperator(pInclusive), DbType.String);
        IDataReader rdr = sp.GetReader();
        this.Load(rdr);
        rdr.Close();
        return this;
    }
     
     #region Constants
     
     public const string VIEW_NAME = "vw_gen_MedianamikExternalRedirect";
     public static readonly Guid TYPE_ID = new Guid("413282ad-8427-472a-93a8-5ad3ecd223aa");
       
       
     #endregion
     
     #region Properties
     
     public int CurrentGeneration
     {
        get; 
        private set;
     }
     
     private int _totalCount;
     /// <summary>
     /// Full items count (when paging is used) 
     /// </summary>
     public int TotalCount
     {
         get
         {
             return _totalCount == 0 ? this.Count : _totalCount;
         }
     }
     
     #endregion  
    }
    /// <summary>
    /// This is  Read-only wrapper class for the vw_gen_MedianamikExternalRedirect view.
    /// </summary>
    [Serializable]
    public partial class MedianamikExternalRedirect : ReadOnlyRecord<MedianamikExternalRedirect>, IReadOnlyRecord, IRecordBase, IMedianamikExternalRedirect
    {
    
       #region Constants
     
     public const string VIEW_NAME = "vw_gen_MedianamikExternalRedirect";
     public static readonly Guid TYPE_ID = new Guid("413282ad-8427-472a-93a8-5ad3ecd223aa");
     public static readonly string TYPE_NAME = "MedianamikExternalRedirect";
     private static readonly Medianamik.Core.Configuration.MedianamikConfigSection CONFIG = (Medianamik.Core.Configuration.MedianamikConfigSection)System.Configuration.ConfigurationManager.GetSection(Medianamik.Core.ConfigurationSectionName.MEDIANAMIK);
       
       
     #endregion
     
     #region Properties
     
     public int CurrentGeneration
     {
        get;
         private set;
     }
     
     #endregion 
        
	    #region Default Settings
	    protected static void SetSQLProps() 
	    {
		    GetTableSchema();
	    }
	    #endregion
        #region Schema Accessor
	    public static TableSchema.Table Schema
        {
            get
            {
                if (BaseSchema == null)
                {
                    SetSQLProps();
                }
                return BaseSchema;
            }
        }
    	
        private static void GetTableSchema() 
        {
            if(!IsSchemaInitialized)
            {
                //Schema declaration
                TableSchema.Table schema = new TableSchema.Table("vw_gen_MedianamikExternalRedirect", TableType.View, DataService.GetInstance("CodeGenerationProvider"));
                schema.Columns = new TableSchema.TableColumnCollection();
                schema.SchemaName = "dbo";
                //columns
                
                TableSchema.TableColumn colvarId = new TableSchema.TableColumn(schema);
                colvarId.ColumnName = "Id";
                colvarId.DataType = DbType.Guid;
                colvarId.MaxLength = 0;
                colvarId.AutoIncrement = false;
                colvarId.IsNullable = false;
                colvarId.IsPrimaryKey = false;
                colvarId.IsForeignKey = false;
                colvarId.IsReadOnly = false;
                
                schema.Columns.Add(colvarId);
                
                TableSchema.TableColumn colvarNodeId = new TableSchema.TableColumn(schema);
                colvarNodeId.ColumnName = "NodeId";
                colvarNodeId.DataType = DbType.Guid;
                colvarNodeId.MaxLength = 0;
                colvarNodeId.AutoIncrement = false;
                colvarNodeId.IsNullable = false;
                colvarNodeId.IsPrimaryKey = false;
                colvarNodeId.IsForeignKey = false;
                colvarNodeId.IsReadOnly = false;
                
                schema.Columns.Add(colvarNodeId);
                
                TableSchema.TableColumn colvarRevision = new TableSchema.TableColumn(schema);
                colvarRevision.ColumnName = "Revision";
                colvarRevision.DataType = DbType.Int32;
                colvarRevision.MaxLength = 0;
                colvarRevision.AutoIncrement = false;
                colvarRevision.IsNullable = true;
                colvarRevision.IsPrimaryKey = false;
                colvarRevision.IsForeignKey = false;
                colvarRevision.IsReadOnly = false;
                
                schema.Columns.Add(colvarRevision);
                
                TableSchema.TableColumn colvarCultureName = new TableSchema.TableColumn(schema);
                colvarCultureName.ColumnName = "CultureName";
                colvarCultureName.DataType = DbType.String;
                colvarCultureName.MaxLength = 10;
                colvarCultureName.AutoIncrement = false;
                colvarCultureName.IsNullable = false;
                colvarCultureName.IsPrimaryKey = false;
                colvarCultureName.IsForeignKey = false;
                colvarCultureName.IsReadOnly = false;
                
                schema.Columns.Add(colvarCultureName);
                
                TableSchema.TableColumn colvarIsActive = new TableSchema.TableColumn(schema);
                colvarIsActive.ColumnName = "IsActive";
                colvarIsActive.DataType = DbType.Boolean;
                colvarIsActive.MaxLength = 0;
                colvarIsActive.AutoIncrement = false;
                colvarIsActive.IsNullable = false;
                colvarIsActive.IsPrimaryKey = false;
                colvarIsActive.IsForeignKey = false;
                colvarIsActive.IsReadOnly = false;
                
                schema.Columns.Add(colvarIsActive);
                
                TableSchema.TableColumn colvarIsSubEntity = new TableSchema.TableColumn(schema);
                colvarIsSubEntity.ColumnName = "IsSubEntity";
                colvarIsSubEntity.DataType = DbType.Boolean;
                colvarIsSubEntity.MaxLength = 0;
                colvarIsSubEntity.AutoIncrement = false;
                colvarIsSubEntity.IsNullable = false;
                colvarIsSubEntity.IsPrimaryKey = false;
                colvarIsSubEntity.IsForeignKey = false;
                colvarIsSubEntity.IsReadOnly = false;
                
                schema.Columns.Add(colvarIsSubEntity);
                
                TableSchema.TableColumn colvarGeneration = new TableSchema.TableColumn(schema);
                colvarGeneration.ColumnName = "Generation";
                colvarGeneration.DataType = DbType.Int32;
                colvarGeneration.MaxLength = 0;
                colvarGeneration.AutoIncrement = false;
                colvarGeneration.IsNullable = false;
                colvarGeneration.IsPrimaryKey = false;
                colvarGeneration.IsForeignKey = false;
                colvarGeneration.IsReadOnly = false;
                
                schema.Columns.Add(colvarGeneration);
                
                TableSchema.TableColumn colvarHasModifications = new TableSchema.TableColumn(schema);
                colvarHasModifications.ColumnName = "HasModifications";
                colvarHasModifications.DataType = DbType.Boolean;
                colvarHasModifications.MaxLength = 0;
                colvarHasModifications.AutoIncrement = false;
                colvarHasModifications.IsNullable = false;
                colvarHasModifications.IsPrimaryKey = false;
                colvarHasModifications.IsForeignKey = false;
                colvarHasModifications.IsReadOnly = false;
                
                schema.Columns.Add(colvarHasModifications);
                
                TableSchema.TableColumn colvarCreatedOn = new TableSchema.TableColumn(schema);
                colvarCreatedOn.ColumnName = "CreatedOn";
                colvarCreatedOn.DataType = DbType.DateTime;
                colvarCreatedOn.MaxLength = 0;
                colvarCreatedOn.AutoIncrement = false;
                colvarCreatedOn.IsNullable = false;
                colvarCreatedOn.IsPrimaryKey = false;
                colvarCreatedOn.IsForeignKey = false;
                colvarCreatedOn.IsReadOnly = false;
                
                schema.Columns.Add(colvarCreatedOn);
                
                TableSchema.TableColumn colvarDepth = new TableSchema.TableColumn(schema);
                colvarDepth.ColumnName = "Depth";
                colvarDepth.DataType = DbType.Int32;
                colvarDepth.MaxLength = 0;
                colvarDepth.AutoIncrement = false;
                colvarDepth.IsNullable = false;
                colvarDepth.IsPrimaryKey = false;
                colvarDepth.IsForeignKey = false;
                colvarDepth.IsReadOnly = false;
                
                schema.Columns.Add(colvarDepth);
                
                TableSchema.TableColumn colvarParentNodeId = new TableSchema.TableColumn(schema);
                colvarParentNodeId.ColumnName = "ParentNodeId";
                colvarParentNodeId.DataType = DbType.Guid;
                colvarParentNodeId.MaxLength = 0;
                colvarParentNodeId.AutoIncrement = false;
                colvarParentNodeId.IsNullable = true;
                colvarParentNodeId.IsPrimaryKey = false;
                colvarParentNodeId.IsForeignKey = false;
                colvarParentNodeId.IsReadOnly = false;
                
                schema.Columns.Add(colvarParentNodeId);
                
                TableSchema.TableColumn colvarPath = new TableSchema.TableColumn(schema);
                colvarPath.ColumnName = "Path";
                colvarPath.DataType = DbType.String;
                colvarPath.MaxLength = 500;
                colvarPath.AutoIncrement = false;
                colvarPath.IsNullable = false;
                colvarPath.IsPrimaryKey = false;
                colvarPath.IsForeignKey = false;
                colvarPath.IsReadOnly = false;
                
                schema.Columns.Add(colvarPath);
                
                TableSchema.TableColumn colvarPosition = new TableSchema.TableColumn(schema);
                colvarPosition.ColumnName = "Position";
                colvarPosition.DataType = DbType.Int16;
                colvarPosition.MaxLength = 0;
                colvarPosition.AutoIncrement = false;
                colvarPosition.IsNullable = false;
                colvarPosition.IsPrimaryKey = false;
                colvarPosition.IsForeignKey = false;
                colvarPosition.IsReadOnly = false;
                
                schema.Columns.Add(colvarPosition);
                
                TableSchema.TableColumn colvarTypeId = new TableSchema.TableColumn(schema);
                colvarTypeId.ColumnName = "TypeId";
                colvarTypeId.DataType = DbType.Guid;
                colvarTypeId.MaxLength = 0;
                colvarTypeId.AutoIncrement = false;
                colvarTypeId.IsNullable = false;
                colvarTypeId.IsPrimaryKey = false;
                colvarTypeId.IsForeignKey = false;
                colvarTypeId.IsReadOnly = false;
                
                schema.Columns.Add(colvarTypeId);
                
                TableSchema.TableColumn colvarModifiedOn = new TableSchema.TableColumn(schema);
                colvarModifiedOn.ColumnName = "ModifiedOn";
                colvarModifiedOn.DataType = DbType.DateTime;
                colvarModifiedOn.MaxLength = 0;
                colvarModifiedOn.AutoIncrement = false;
                colvarModifiedOn.IsNullable = true;
                colvarModifiedOn.IsPrimaryKey = false;
                colvarModifiedOn.IsForeignKey = false;
                colvarModifiedOn.IsReadOnly = false;
                
                schema.Columns.Add(colvarModifiedOn);
                
                TableSchema.TableColumn colvarCreatedBy = new TableSchema.TableColumn(schema);
                colvarCreatedBy.ColumnName = "CreatedBy";
                colvarCreatedBy.DataType = DbType.String;
                colvarCreatedBy.MaxLength = 100;
                colvarCreatedBy.AutoIncrement = false;
                colvarCreatedBy.IsNullable = true;
                colvarCreatedBy.IsPrimaryKey = false;
                colvarCreatedBy.IsForeignKey = false;
                colvarCreatedBy.IsReadOnly = false;
                
                schema.Columns.Add(colvarCreatedBy);
                
                TableSchema.TableColumn colvarExtendedData = new TableSchema.TableColumn(schema);
                colvarExtendedData.ColumnName = "ExtendedData";
                colvarExtendedData.DataType = DbType.AnsiString;
                colvarExtendedData.MaxLength = -1;
                colvarExtendedData.AutoIncrement = false;
                colvarExtendedData.IsNullable = false;
                colvarExtendedData.IsPrimaryKey = false;
                colvarExtendedData.IsForeignKey = false;
                colvarExtendedData.IsReadOnly = false;
                
                schema.Columns.Add(colvarExtendedData);
                
                TableSchema.TableColumn colvarRedirectFrom = new TableSchema.TableColumn(schema);
                colvarRedirectFrom.ColumnName = "RedirectFrom";
                colvarRedirectFrom.DataType = DbType.AnsiString;
                colvarRedirectFrom.MaxLength = -1;
                colvarRedirectFrom.AutoIncrement = false;
                colvarRedirectFrom.IsNullable = true;
                colvarRedirectFrom.IsPrimaryKey = false;
                colvarRedirectFrom.IsForeignKey = false;
                colvarRedirectFrom.IsReadOnly = false;
                
                schema.Columns.Add(colvarRedirectFrom);
                
                TableSchema.TableColumn colvarRedirectTo = new TableSchema.TableColumn(schema);
                colvarRedirectTo.ColumnName = "RedirectTo";
                colvarRedirectTo.DataType = DbType.AnsiString;
                colvarRedirectTo.MaxLength = -1;
                colvarRedirectTo.AutoIncrement = false;
                colvarRedirectTo.IsNullable = true;
                colvarRedirectTo.IsPrimaryKey = false;
                colvarRedirectTo.IsForeignKey = false;
                colvarRedirectTo.IsReadOnly = false;
                
                schema.Columns.Add(colvarRedirectTo);
                
                TableSchema.TableColumn colvarRedirectCode = new TableSchema.TableColumn(schema);
                colvarRedirectCode.ColumnName = "RedirectCode";
                colvarRedirectCode.DataType = DbType.Int32;
                colvarRedirectCode.MaxLength = 0;
                colvarRedirectCode.AutoIncrement = false;
                colvarRedirectCode.IsNullable = true;
                colvarRedirectCode.IsPrimaryKey = false;
                colvarRedirectCode.IsForeignKey = false;
                colvarRedirectCode.IsReadOnly = false;
                
                schema.Columns.Add(colvarRedirectCode);
                
                
                BaseSchema = schema;
                //add this schema to the provider
                //so we can query it later
                DataService.Providers["CodeGenerationProvider"].AddSchema("vw_gen_MedianamikExternalRedirect",schema);
            }
        }
        #endregion
        
        #region Query Accessor
	    public static Query CreateQuery()
	    {
		    return new Query(Schema);
	    }
	    #endregion
	    
	    #region .ctors
	    public MedianamikExternalRedirect()
	    {
            SetSQLProps();
            SetDefaults();
            MarkNew();
        }
        private MedianamikExternalRedirect(bool useDatabaseDefaults)
	    {
		    SetSQLProps();
		    if(useDatabaseDefaults)
		    {
				ForceDefaults();
			}
			MarkNew();
	    }
	    
	    private MedianamikExternalRedirect(object keyID)
	    {
		    SetSQLProps();
		    LoadByKey(keyID);
	    }
    	 
	    private MedianamikExternalRedirect(string columnName, object columnValue)
        {
            SetSQLProps();
            LoadByParam(columnName,columnValue);
        }
        #region Medianamik
        
        public MedianamikExternalRedirect(Guid pNodeId, string pCultureName, ContentState state): this(pNodeId, pCultureName, (int)state)
        { }
        public MedianamikExternalRedirect(Guid pNodeId, string pCultureName):this(pNodeId, pCultureName, default(int?))
        { }
        public MedianamikExternalRedirect(Guid pNodeId): this(pNodeId, System.Globalization.CultureInfo.CurrentUICulture.Name, default(int?))
        { }
        
        private MedianamikExternalRedirect(Guid pNodeId, string pCultureName, int? pContentState): this()
        {
            if(pContentState.HasValue)
            {
                CurrentGeneration = pContentState.Value;
            }
            else
            {
                CurrentGeneration = System.Web.HttpContext.Current == null
                    ? (int)ContentState.Published
                    : new Medianamik.Client.Utility().GetGeneration(System.Web.HttpContext.Current.Request);
            }
            
            Query q = MedianamikExternalRedirect.Query();
            q.WHERE("NodeId", pNodeId.ToString());
            q.WHERE("CultureName", pCultureName);
            q.WHERE("Generation", CurrentGeneration);
            this.LoadAndCloseReader(q.ExecuteReader());
            
        } 
        
        
        
        #endregion
        
	    #endregion
	    
	    #region Props
	    
          
        [XmlAttribute("Id")]
        [Bindable(true)]
        public Guid Id 
	    {
		    get
		    {
			    return GetColumnValue<Guid>("Id");
		    }
		    set
		    {
		        base.SetColumnValue("Id", value);
		    }
        }
	      
        [XmlAttribute("NodeId")]
        [Bindable(true)]
        public Guid NodeId 
	    {
		    get
		    {
			    return GetColumnValue<Guid>("NodeId");
		    }
		    set
		    {
		        base.SetColumnValue("NodeId", value);
		    }
        }
	      
        [XmlAttribute("Revision")]
        [Bindable(true)]
        public int? Revision 
	    {
		    get
		    {
			    return GetColumnValue<int?>("Revision");
		    }
		    set
		    {
		        base.SetColumnValue("Revision", value);
		    }
        }
	      
        [XmlAttribute("CultureName")]
        [Bindable(true)]
        public string CultureName 
	    {
		    get
		    {
			    return GetColumnValue<string>("CultureName");
		    }
		    set
		    {
		        base.SetColumnValue("CultureName", value);
		    }
        }
	      
        [XmlAttribute("IsActive")]
        [Bindable(true)]
        public bool IsActive 
	    {
		    get
		    {
			    return GetColumnValue<bool>("IsActive");
		    }
		    set
		    {
		        base.SetColumnValue("IsActive", value);
		    }
        }
	      
        [XmlAttribute("IsSubEntity")]
        [Bindable(true)]
        public bool IsSubEntity 
	    {
		    get
		    {
			    return GetColumnValue<bool>("IsSubEntity");
		    }
		    set
		    {
		        base.SetColumnValue("IsSubEntity", value);
		    }
        }
	      
        [XmlAttribute("Generation")]
        [Bindable(true)]
        public int Generation 
	    {
		    get
		    {
			    return GetColumnValue<int>("Generation");
		    }
		    set
		    {
		        base.SetColumnValue("Generation", value);
		    }
        }
	      
        [XmlAttribute("HasModifications")]
        [Bindable(true)]
        public bool HasModifications 
	    {
		    get
		    {
			    return GetColumnValue<bool>("HasModifications");
		    }
		    set
		    {
		        base.SetColumnValue("HasModifications", value);
		    }
        }
	      
        [XmlAttribute("CreatedOn")]
        [Bindable(true)]
        public DateTime CreatedOn 
	    {
		    get
		    {
			    return GetColumnValue<DateTime>("CreatedOn");
		    }
		    set
		    {
		        base.SetColumnValue("CreatedOn", value);
		    }
        }
	      
        [XmlAttribute("Depth")]
        [Bindable(true)]
        public int Depth 
	    {
		    get
		    {
			    return GetColumnValue<int>("Depth");
		    }
		    set
		    {
		        base.SetColumnValue("Depth", value);
		    }
        }
	      
        [XmlAttribute("ParentNodeId")]
        [Bindable(true)]
        public Guid? ParentNodeId 
	    {
		    get
		    {
			    return GetColumnValue<Guid?>("ParentNodeId");
		    }
		    set
		    {
		        base.SetColumnValue("ParentNodeId", value);
		    }
        }
	      
        [XmlAttribute("Path")]
        [Bindable(true)]
        public string Path 
	    {
		    get
		    {
			    return GetColumnValue<string>("Path");
		    }
		    set
		    {
		        base.SetColumnValue("Path", value);
		    }
        }
	      
        [XmlAttribute("Position")]
        [Bindable(true)]
        public short Position 
	    {
		    get
		    {
			    return GetColumnValue<short>("Position");
		    }
		    set
		    {
		        base.SetColumnValue("Position", value);
		    }
        }
	      
        [XmlAttribute("TypeId")]
        [Bindable(true)]
        public Guid TypeId 
	    {
		    get
		    {
			    return GetColumnValue<Guid>("TypeId");
		    }
		    set
		    {
		        base.SetColumnValue("TypeId", value);
		    }
        }
	      
        [XmlAttribute("ModifiedOn")]
        [Bindable(true)]
        public DateTime? ModifiedOn 
	    {
		    get
		    {
			    return GetColumnValue<DateTime?>("ModifiedOn");
		    }
		    set
		    {
		        base.SetColumnValue("ModifiedOn", value);
		    }
        }
	      
        [XmlAttribute("CreatedBy")]
        [Bindable(true)]
        public string CreatedBy 
	    {
		    get
		    {
			    return GetColumnValue<string>("CreatedBy");
		    }
		    set
		    {
		        base.SetColumnValue("CreatedBy", value);
		    }
        }
	      
        [XmlAttribute("ExtendedData")]
        [Bindable(true)]
        public string ExtendedData 
	    {
		    get
		    {
			    return GetColumnValue<string>("ExtendedData");
		    }
		    set
		    {
		        base.SetColumnValue("ExtendedData", value);
		    }
        }
	      
        [XmlAttribute("RedirectFrom")]
        [Bindable(true)]
        public string RedirectFrom 
	    {
		    get
		    {
			    return GetColumnValue<string>("RedirectFrom");
		    }
		    set
		    {
		        base.SetColumnValue("RedirectFrom", value);
		    }
        }
	      
        [XmlAttribute("RedirectTo")]
        [Bindable(true)]
        public string RedirectTo 
	    {
		    get
		    {
			    return GetColumnValue<string>("RedirectTo");
		    }
		    set
		    {
		        base.SetColumnValue("RedirectTo", value);
		    }
        }
	      
        [XmlAttribute("RedirectCode")]
        [Bindable(true)]
        public int? RedirectCode 
	    {
		    get
		    {
			    return GetColumnValue<int?>("RedirectCode");
		    }
		    set
		    {
		        base.SetColumnValue("RedirectCode", value);
		    }
        }
	    
	    public System.Globalization.CultureInfo Culture
        {
            get { return System.Globalization.CultureInfo.GetCultureInfo(CultureName); }
        } 
	    
	    #endregion
	    
	    #region Methods
	    	    	    
	    public static MedianamikExternalRedirect FetchByNodeID(Guid? pNodeId, string pCultureName, ContentState pState)
	    {
	        if(pNodeId.HasValue) { return new MedianamikExternalRedirect(pNodeId.Value,pCultureName, pState) ; }
	        else return new MedianamikExternalRedirect();
	    }
	    	    
	    public static System.Web.Caching.CacheDependency GetCacheDependency()
        {
            System.Web.Caching.SqlCacheDependency[] deps = new System.Web.Caching.SqlCacheDependency[]
                {
                
                    new System.Web.Caching.SqlCacheDependency ("Medianamik.Client", "gen_MedianamikExternalRedirect"),
                    
                };
                
                
            System.Web.Caching.AggregateCacheDependency aggDep = new System.Web.Caching.AggregateCacheDependency();
            
            
            aggDep.Add(deps);
            
            return aggDep;
        }
	    
	    #endregion
	    
	    #region foreign Relations
	    
	    
	    
	    #endregion
	    
	    #region primary Relations
	    
	    
	    
	    #endregion
	    
	    #region ManyToManyRelations
	    
	    
	    
	    #endregion
    
	    #region Columns Struct
	    public struct Columns
	    {
		    
		    
            public static string Id = @"Id";
            
            public static string NodeId = @"NodeId";
            
            public static string Revision = @"Revision";
            
            public static string CultureName = @"CultureName";
            
            public static string IsActive = @"IsActive";
            
            public static string IsSubEntity = @"IsSubEntity";
            
            public static string Generation = @"Generation";
            
            public static string HasModifications = @"HasModifications";
            
            public static string CreatedOn = @"CreatedOn";
            
            public static string Depth = @"Depth";
            
            public static string ParentNodeId = @"ParentNodeId";
            
            public static string Path = @"Path";
            
            public static string Position = @"Position";
            
            public static string TypeId = @"TypeId";
            
            public static string ModifiedOn = @"ModifiedOn";
            
            public static string CreatedBy = @"CreatedBy";
            
            public static string ExtendedData = @"ExtendedData";
            
            public static string RedirectFrom = @"RedirectFrom";
            
            public static string RedirectTo = @"RedirectTo";
            
            public static string RedirectCode = @"RedirectCode";
            
	    }
	    #endregion
	    
	    
	    #region IAbstractRecord Members
        public new CT GetColumnValue<CT>(string columnName) {
            return base.GetColumnValue<CT>(columnName);
        }
        public object GetColumnValue(string columnName) {
            return base.GetColumnValue<object>(columnName);
        }
        #endregion
	    
    }
    
    #region Medianamik 
    
    
    public partial interface IMedianamikExternalRedirect : IMedianamikDTO 
    {
          
        string RedirectFrom 
	    {
		    get;
        }
	      
        string RedirectTo 
	    {
		    get;
        }
	      
        int? RedirectCode 
	    {
		    get;
        }
	    
	    
	    
    }
    
    #region BasePage
     
    
    #endregion
    
    #endregion
    
    
    
    
}
